<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0,viewport-fit=cover" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../css/base.css" />
    <link rel="stylesheet" type="text/css" href="../css/local.css" />
    <script type="text/javascript" src="../script/jquery.js"></script>
    <script type="text/javascript" src="../script/layer/mobile/layer.js"></script>
    <script type="text/javascript" src="../script/vue.min.js"></script>
    <script type="text/javascript" src="../script/vant.min.js"></script>
    <script type="text/javascript" src="../script/fastclick.js"></script>
    <script type="text/javascript" src="../script/base.js"></script>
    <style type="text/css">
        .title {
            font-size: 17px;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
            word-break: break-all;
            padding-right: 10px;
        }

        .date {
            /* float: right; */
            font-size: 14px;
            /* color: #cbcbcb; */
        }

        .sub {
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
            word-break: break-all;
            font-size: 14px;
            color: #a3a3a3;
        }

        .creater {
            font-size: 14px;
        }

        .creater2 {
            font-size: 12px;
        }

        .result span {
            background: #fdf9f8;
            border: 1px solid #eeebec;
            border-radius: 10px;
            font-size: 12px;
            transform: scale(0.9);
            display: inline-block;
            height: 16px;
            line-height: 14px;
            padding: 0 2px;
        }

        .status-0 span {
            transform: scale(1);
            border: 0;
            background: #ffffff;
            color: #e3b474;
        }

        .status-1 span {
            color: #47ba9c;
        }

        .status-2 span {
            color: #dd7e70;
        }

        .bo {
            padding-top: 10px;
        }

        .sq {
            display: inline-block;
            font-size: 13px;
            padding: 0 2px;
            margin-right: 5px;
            min-width: 16px;
            height: 18px;
            line-height: 18px;
            border-radius: 4px;
            text-align: center;
            background-color: #3396fb;
            color: #ffffff;

        }

        .title span {
            vertical-align: middle;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="box" style="user-select:none;">
            <van-nav-bar-main :title="titleName" left-arrow @click-left="onClickLeft">
                <!-- <div slot="right">
                     <span @click="showSearch = true;">
                         <van-icon name="search" size="18px"></van-icon>
                     </span>
                 </div> -->
            </van-nav-bar-main>

            <div class="content">
                <van-list v-model="listLoading" :finished="listFinished" finished-text="没有更多了" @load="listOnLoad">
                    <van-cell-group>
                        <van-cell @click="intoRow(row)" v-for="(row,index) in dataList">
                            <div>
                                <van-row>
                                    <van-col span="24">
                                        <div class="flex-box">
                                            <div class="title"><span class="sq">{{index+1}}</span></div>
                                            <div class="date">{{row.MSGSubject}}</div>
                                        </div>
                                    </van-col>

                                    <van-col span="24">
                                        <div class="flex-box bo">
                                            {{row.MSGContent}}
                                        </div>
                                    </van-col>

                                    <van-col span="24">
                                        <div class="flex-box bo">
                                            {{row.SendDate}}
                                        </div>
                                    </van-col>
                                </van-row>
                            </div>
                        </van-cell>
                    </van-cell-group>


                </van-list>

            </div>
        </div>
    </div>
</body>
<script type="text/javascript">
    var vm;
    apiready = function () {

        api.addEventListener({
            name: 'refreshList'
        }, function (ret, err) {
            vm.pageIndex = 1;
            vm.getDataList();
        })

        var dateIndex = 0;

        vm = new Vue({
            el: '#app',
            data: {
                showLoading: false,
                showSearch: false,
                titleName: api.pageParam.titleName,
                listLoading: false,
                listFinished: true,
                pageSize: 30,
                pageIndex: 1,
                dataList: [],
                currentDate: new Date(),
                showDate: false,
                searchData: {}
            },
            created: function () {
                var that = this;
                that.getDataList();
            },
            methods: {
                getDataList: function () {
                    var that = this;
                    that.showLoading = true;
                    var obj = {
                        pageIndex: that.pageIndex,
                        pageSize: that.pageSize
                    }
                    APP.ajax('getPzMsgList', obj, function (res) {
                        // console.log(JSON.stringify(res))
                        that.showLoading = false;
                        that.listFinished = false;
                        that.dataList = res.ds;

                        that.dateFormat();
                    })

                },
                listOnLoad: function () {
                    var that = this;
                    that.pageIndex++;
                    var obj = {
                        pageIndex: that.pageIndex,
                        pageSize: that.pageSize
                    }
                    APP.ajax('getPzMsgList', obj, function (res) {
                        that.listLoading = false;
                        if (res.ds.length == 0) {
                            that.listFinished = true;
                        }
                        that.dataList = that.dataList.concat(res.ds);

                        that.dateFormat();
                    })
                },
                intoRow: function (row) {
                    api.openWin({
                        name: 'pzMsgDtlList',
                        url: 'pzMsgDtlList.html',
                        reload: true,
                        slidBackEnabled: false,
                        allowEdit: true,
                        pageParam: {
                            titleName: '消息详情',
                            MSGContent: row.MSGContent,
                            BDate: row.SendDate
                        }
                    })
                },
                dateFormat: function () {
                    for (var i in vm.dataList) {
                        var row = vm.dataList[i];
                        if (row.SendDate) {
                            row.SendDate = row.SendDate.split('.')[0].replace('T', ' ');
                        } else {
                            row.SendDate = '';
                        }
                    }
                },
                onClickLeft: function () {
                    api.closeWin();
                }
            }
        })

    };
</script>

</html>